# $Id$
# Maintainer: Sven-Hendrik Haase <sh@lutzhaase.com>

pkgname=sdl2
pkgver=2.0.8
pkgrel=9
pkgdesc="A library for portable low-level access to a video framebuffer, audio output, mouse, and keyboard (Version 2)"
arch=('x86_64')
url="https://www.libsdl.org"
license=('MIT')
depends=('glibc' 'libxext' 'libxrender' 'libx11' 'libgl' 'libxcursor' 'libibus')
makedepends=('alsa-lib' 'mesa' 'libpulse' 'libxrandr' 'libxinerama' 'wayland' 'libxkbcommon'
             'wayland-protocols' 'ibus' 'fcitx' 'libxss' 'cmake')
optdepends=('alsa-lib: ALSA audio driver'
            'libpulse: PulseAudio audio driver')
source=("https://www.libsdl.org/release/SDL2-${pkgver}.tar.gz"{,.sig}
        cmake-include-paths.patch dynapi.patch)
sha512sums=('673c6058b8692a36b4a3594456b10ef6051efe79e4fb644421fc5c76b11fd68b895840a2c8b72413418c378733e2993d33f19767d0d7ed101eda6310bd70c869'
            'SKIP'
            '53eb853153b189bd9c0978ab8c7375608b6df5fc78e22168505bf9f6e695f6fbdc553eead0b17deb734002e047c6d5ae06642363fc629aa9ab7bef0c30388c84'
            'bdb634b070af2f67fddcdd7908fe9ec0ea49d6edb013c35aaf1dbc840f941072ee16b21e5158de500aa5ec81165780a3aaf03e27d8bb30d50c2efb2a5465f824')
validpgpkeys=('1528635D8053A57F77D1E08630A59377A7763BE6') # Sam Lantinga

prepare() {
  cd SDL2-${pkgver}

  patch -Np1 -i "${srcdir}"/cmake-include-paths.patch

  # Taken from Fedora; fixes "Firewatch" and "Enter the Gungeon"
  patch -Np1 -i "${srcdir}"/dynapi.patch

  rm -rf build
  mkdir build
}

build() {
  cd SDL2-${pkgver}/build
  cmake .. \
      -DCMAKE_INSTALL_PREFIX=/usr \
      -DSDL_STATIC=OFF \
      -DSDL_DLOPEN=ON \
      -DARTS=OFF \
      -DESD=OFF \
      -DNAS=OFF \
      -DALSA=ON \
      -DPULSEAUDIO_SHARED=ON \
      -DVIDEO_WAYLAND=ON \
      -DRPATH=OFF \
      -DCLOCK_GETTIME=ON
  make
}

package() {
  cd SDL2-${pkgver}/build

  make DESTDIR="${pkgdir}" install

  sed -i "s/libSDL2\.a/libSDL2main.a/g" "$pkgdir"/usr/lib/cmake/SDL2/SDL2Targets-noconfig.cmake

  install -Dm644 ../COPYING.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

# vim: ts=2 sw=2 et:
